# Maintainer: Alexandre Ferreira < alex.jorge.m [at] gmail.com >

pkgname=ansible
pkgver=2.9.11
pkgrel=1
pkgdesc='Radically simple IT automation platform'
arch=('i686' 'x86_64')
url='https://www.ansible.com'
license=('GPL3')
depends=('python' 'python-yaml' 'python-jinja')
provides=('python-ansible')
optdepends=('sshpass: for ssh connections with password')
makedepends=('tar' 'python-setuptools')
backup=('etc/ansible/ansible.cfg')
source=("https://releases.ansible.com/ansible/ansible-${pkgver}.tar.gz")
sha512sums=('b157a5cfb5ba7cb651c7afc0dc92cfe3b8f9eebd06de6d7a1e4917ffca3c542c5207c8e1820acc5be840190c8754f111e2501304ad7e64867247e5b973aec81e')
noextract=("${pkgname}-${pkgver}.tar.gz")

prepare() {
  [[ -d ${pkgname}-${pkgver} ]] && rm -rf ${pkgname}-${pkgver}
  # Workaround an issue with symbolic links in the tarball.
  tar zxf "${srcdir}/${pkgname}-${pkgver}.tar.gz" || true
  MSYS=winsymlinks:lnk tar zxf "${srcdir}/${pkgname}-${pkgver}.tar.gz"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  /usr/bin/python setup.py build
}

package() {
  cd ${pkgname}-${pkgver}
  /usr/bin/python setup.py install -O1 --root="${pkgdir}"
  install -Dm644 COPYING "${pkgdir}"/usr/share/doc/ansible/COPYING

  install -d "${pkgdir}"/usr/share/ansible/doc
  cp -dpr --no-preserve=ownership ./examples "${pkgdir}"/usr/share/ansible/doc/
  install -Dm644 examples/ansible.cfg "${pkgdir}"/etc/ansible/ansible.cfg

  install -d "${pkgdir}"/usr/share/man/man1
  cp -dpr --no-preserve=ownership docs/man/man1/*.1 "${pkgdir}"/usr/share/man/man1
}
